package servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;

@WebServlet(name = "AjaxServlet", value = "/AjaxServlet")
public class AjaxServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;Charset=utf-8");
        response.setHeader("Access-Control-Allow-Origin","*");
        System.out.println("开始交互");
        String flightType = request.getParameter("FlightType");
        String price = request.getParameter("Price");
        String seat =  request.getParameter("Seat");
        String passenger = request.getParameter("Passenger");
        String card = request.getParameter("Card");
        String[] other = request.getParameterValues("LuggageInformation");
        System.out.println(other.length);
        for (String s : other) {
            System.out.println(s);
        }
        System.out.println(flightType + "||" + price+ "||" + seat+ "||" + passenger+ "||" + card+ Arrays.toString(other));
        PrintWriter out = response.getWriter();
        out.write("我已经收到你的消息");
        out.println("收到");
        out.flush();
        out.close();
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
